<template>
  <div>
      <p :style="{'backgroundColor':`rgb(${r} ,${g} , ${b})`}"></p>
      <button @click="btn">点击改变随机背景颜色</button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      r: 10,
      g: 5,
      b: 20
    }
  },
  methods: {
    btn () {
      this.r = Math.floor(Math.random() * (255 - 0 + 1))
      this.g = Math.floor(Math.random() * (255 - 0 + 1))
      this.b = Math.floor(Math.random() * (255 - 0 + 1))
    }
  }
}
</script>

<style>
    P {
        width: 60PX;
        height: 60PX;
    }
</style>
